package jaxb;

import java.time.LocalDate;
import java.time.format.DateTimeFormatter;
import javax.xml.bind.annotation.adapters.XmlAdapter;

/**
 *
 * @author LiShixi
 */
public class LocalDateAdapter extends XmlAdapter<String, LocalDate> {

    @Override
    public LocalDate unmarshal(String v) throws Exception {
        return LocalDate.parse(v);
    }

    @Override
    public String marshal(LocalDate v) throws Exception {

        return DateTimeFormatter.ofPattern("yyyy MM-dd").format(v);
    }

    public static void main(String[] args) {
        System.out.println(DateTimeFormatter.ofPattern("yyyy MM-dd").format(LocalDate.now()));
    }

}
